/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package reasoner;

import DataTypes.AutoDiaryDataTypes;
import DataTypes.AutoDiaryDataTypes.AmbiLiteral;
import java.util.ArrayList;

/**
 *
 * @author thang
 */
public class Test {
    public static void main(String[] agrs){
        //ComplexSituation.startComplexReasoning();
        //String test = "Best model: {actAndTime(samGIIFei,147651,1337904720,2012,5,25,Friday,10,12,0,walking), actAddress(147651,20318,1337904718,10,1,13918,Science Dr, Bundoora VIC 3083, Australia,129), recentGpsAddress(147651,20318,1337904718,10,1,13918,Science Dr, Bundoora VIC 3083, Australia,129), actPlaces(20318,72516,2964,Bundoora,locality,13919,Bundoora VIC 3083, Australia,\"null\"), actPlaces(20318,72516,2964,Bundoora,political,13919,Bundoora VIC 3083, Australia,\"null\"), actPlaces(20318,72515,129,Science Dr,route,13918,Science Dr, Bundoora VIC 3083, Australia,129), userPlaces(2,76833,506,Science Dr, Bundoora VIC 3083, Australia), userPlaces(2,76834,501,19 Sunburst Ave, Balwyn North VIC 3104, Australia), distanceToHome1(8172), distanceToOffice1(174), gpsAddress(gpsIdNull,gpsAddressIdNull,gpsAddressNull,1000), gpsAddress(20318,13918,Science Dr, Bundoora VIC 3083, Australia,129), places(placeIdNull,placeNameNull,1000,placeAddressNull), places(72516,Bundoora,2964,Bundoora VIC 3083, Australia), places(72515,Science Dr,129,Science Dr, Bundoora VIC 3083, Australia), device(samGIIFei), primActivity(147651,walking,1337904720), timeInt(1337904720), timeYear(1337904720,2012), timeMonth(1337904720,5), timeDate(1337904720,25), timeDay(1337904720,Friday), timeHour(1337904720,10), timeMinute(1337904720,12), timeSecond(1337904720,0), gps(147651,20318,1337904718,10,1), closestAddress(20318,13918,Science Dr, Bundoora VIC 3083, Australia,129), recentGps(20318,1337904718,10), placeType(72516,locality), placeType(72516,political), placeType(72515,route), minPlaceDistance(129), closestPlaces(72515,Science Dr,129,Science Dr, Bundoora VIC 3083, Australia), userAt(place,72515), userAt(506,20318), activity(outdoor,1337904718), activity(walking,1337904720), userAtPlace(office1,20318,1337904718), userAtPlaceCode(506,20318,1337904718), knownPlace(office1)}" ;
        //WindowReasoner.getDeviceId(test);
        //WindowReasoner.logKnownPlace(test);
        
        //testEliminateGroup();
        testClassification();
       
        //System.out.println(autodiaryserver.Declare.DEVICE_ID);
        
        //WindowReasoner.putActToWindow();
    }
    
    public static void testEliminateGroup()
    {
        AutoDiaryDataTypes.AmbiLiteral a = new AutoDiaryDataTypes.AmbiLiteral();
        a.code = "undercover";
        AutoDiaryDataTypes.AmbiLiteral b = new AutoDiaryDataTypes.AmbiLiteral();
        b.code = "stayingStill";

        boolean test = WindowReasoner.eliminated(a, b);
        System.out.println("Eliminated walking and stayingStill: " + test);
    }
    
    public static void testClassification(){
        AutoDiaryDataTypes.AmbiLiteral a = new AutoDiaryDataTypes.AmbiLiteral();
        a.code = "undercover";
        a.memberValue = 3;
        AutoDiaryDataTypes.AmbiLiteral b = new AutoDiaryDataTypes.AmbiLiteral();
        b.code = "stayingStill";
        b.memberValue = 5;
        AutoDiaryDataTypes.AmbiLiteral c = new AutoDiaryDataTypes.AmbiLiteral();
        c.code = "driving";
        c.memberValue = 4;

        AutoDiaryDataTypes.WeightMatrix wMatrix = new AutoDiaryDataTypes.WeightMatrix();
        ArrayList<AutoDiaryDataTypes.RelationGroup> groups = new ArrayList<AutoDiaryDataTypes.RelationGroup>(); 

        wMatrix.device_id = "samGIIFei";
        wMatrix.time = 1234567890;
        wMatrix.windowWeight = 5;
        wMatrix.matrix = new ArrayList<AmbiLiteral>();
        wMatrix.matrix.add(a);
        wMatrix.matrix.add(b);
        wMatrix.matrix.add(c);
        
        
        WindowReasoner.classifyIntoGroups(wMatrix, groups);
        for( AutoDiaryDataTypes.RelationGroup rg: groups ){
            System.out.println("Relation: " + rg.relation);
            for( AmbiLiteral al: rg.group ){
                System.out.println("Activity: " + al.code);
            }
            System.out.println();
        }
        
        ArrayList<AmbiLiteral> dominants = WindowReasoner.selectDominants(groups);
        System.out.println("Dominant activities:");
        for( AmbiLiteral al: dominants ){
            System.out.println("Activity: " + al.code + ", Membership value: " + al.memberValue);
        }
        
    }
}
